
package com.click.app.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author ariel
 */
@Entity
@Table(name="payments_laundry")
public class PaymentsLaundry extends BaseObject implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private Date datePay;
    private Double amount;
    private String code;
    private PeriodPaymentLaundry periodPaymentLaundry;
    private List<AsignationRequestLaundryPay> asignationRequestLaundryPay;
    private BalanceLaundry balanceLaundry;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_payments_laundry", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "date_pay")
    @Temporal(value = javax.persistence.TemporalType.DATE)
    public Date getDatePay() {
        return datePay;
    }

    public void setDatePay(Date datePay) {
        this.datePay = datePay;
    }

    @Column(name = "code")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    @JoinColumn(name = "id_period_payment_laundry")
    @ManyToOne(optional = false)
    public PeriodPaymentLaundry getPeriodPaymentLaundry() {
        return periodPaymentLaundry;
    }

    public void setPeriodPaymentLaundry(PeriodPaymentLaundry periodPaymentLaundry) {
        this.periodPaymentLaundry = periodPaymentLaundry;
    }

    @OneToMany(cascade=CascadeType.REMOVE, mappedBy="paymentsLaundry")
    public List<AsignationRequestLaundryPay> getAsignationRequestLaundryPay() {
        return asignationRequestLaundryPay;
    }

    public void setAsignationRequestLaundryPay(List<AsignationRequestLaundryPay> asignationRequestLaundryPay) {
        this.asignationRequestLaundryPay = asignationRequestLaundryPay;
    }

    @OneToOne(cascade=CascadeType.REMOVE, mappedBy = "paymentsLaundry")
    public BalanceLaundry getBalanceLaundry() {
        return balanceLaundry;
    }

    public void setBalanceLaundry(BalanceLaundry balanceLaundry) {
        this.balanceLaundry = balanceLaundry;
    }

    @Override
    public String toString() {
       return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                    .append(this.id).append(this.code).append(this.datePay).append(this.amount).toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PaymentsLaundry other = (PaymentsLaundry) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.datePay != other.datePay && (this.datePay == null || !this.datePay.equals(other.datePay))) {
            return false;
        }
        if (this.amount != other.amount && (this.amount == null || !this.amount.equals(other.amount))) {
            return false;
        }
        if (this.periodPaymentLaundry != other.periodPaymentLaundry && (this.periodPaymentLaundry == null || !this.periodPaymentLaundry.equals(other.periodPaymentLaundry))) {
            return false;
        }
        if (this.asignationRequestLaundryPay != other.asignationRequestLaundryPay && (this.asignationRequestLaundryPay == null || !this.asignationRequestLaundryPay.equals(other.asignationRequestLaundryPay))) {
            return false;
        }
        if (this.balanceLaundry != other.balanceLaundry && (this.balanceLaundry == null || !this.balanceLaundry.equals(other.balanceLaundry))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 37 * hash + (this.datePay != null ? this.datePay.hashCode() : 0);
        hash = 37 * hash + (this.amount != null ? this.amount.hashCode() : 0);
        hash = 37 * hash + (this.periodPaymentLaundry != null ? this.periodPaymentLaundry.hashCode() : 0);
        hash = 37 * hash + (this.asignationRequestLaundryPay != null ? this.asignationRequestLaundryPay.hashCode() : 0);
        hash = 37 * hash + (this.balanceLaundry != null ? this.balanceLaundry.hashCode() : 0);
        return hash;
    }

    

}
